package com.lindroy.jetpacknotes.navigation.args.fragment

import android.os.Bundle
import androidx.navigation.fragment.findNavController
import com.lindroy.jetpacknotes.R
import com.lindroy.jetpacknotes.base.BaseFragment
import com.lindroy.jetpacknotes.constants.KEY_AGE
import com.lindroy.jetpacknotes.constants.KEY_NAME
import com.lindroy.jetpacknotes.navigation.args.fragment.SenderFragmentArgs.*
import kotlinx.android.synthetic.main.fragment_sender.*

class SenderFragment : BaseFragment(R.layout.fragment_sender) {

    override fun initView(savedInstanceState: Bundle?) {

        btnBundle.setOnClickListener {
            val bundle = Bundle()
            bundle.putString(KEY_NAME, "李雷")
            bundle.putInt(KEY_AGE, 17)
            findNavController().navigate(R.id.action_sender_to_receiver, bundle)
        }
        btnSafe.setOnClickListener {
            val bundle = Builder()
                .setName("韩梅梅")
                .setAge(16)
                .build()
                .toBundle()
            findNavController().navigate(R.id.action_sender_to_receiver, bundle)
        }
    }

    override fun initListener() {
    }

}